<?php

if(!defined('_HTML_BASE_')) {
define('_HTML_BASE_', 1);

function itstock_html_header() {
?>
<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="main.php">IT Stock</a>
    </div>
    <div class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
      <li class="dropdown">
          <a data-toggle="dropdown" href="#">Inventory <b class="caret"></b></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="main.php?page=hardware">Hardware</a></li>
            <li class="divider"></li>
            <li><a href="main.php?page=software">Software</a></li>
          </ul>
      </li>
      <li><a href="main.php?page=cpu">Computer Case</a></li>
      <li><a href="main.php?page=location">Cubicles</a></li>
      <li><a href="main.php?page=warehouse">Warehouse</a></li>
      <li><a href="main.php?page=order">Orders</a></li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
        <a data-toggle="dropdown" href="#">Welcome <?php echo itstock_ldap_get($_SESSION['user'], 'givenname'); ?>! <b class="caret"></b></a>
        <ul class="dropdown-menu" role="menu">
          <li><a href="settings.php">Settings</a></li>
          <li class="divider"></li>
          <li><a href="logout.php?logout">Logout</a></li>
        </ul>
        </li>
    </ul>
    </div>
  </div>
</div>
<?php
}

function itstock_html_print_css(&$info) {
  if(isset($info['css']) && is_array($info['css'])) {
    foreach($info['css'] as $css){
      if (file_exists(_ITSTOCK_CSS_DIR_ . $css)) {
        echo '<link href="'. _ITSTOCK_CSS_DIR_ . $css .'" type="text/css" rel="stylesheet" />';
      }
    }
  }
}

function itstock_html_print_js(&$info) {
  if(isset($info['js']) && is_array($info['js'])) {
    foreach($info['js'] as $js){
      if (file_exists(_ITSTOCK_JS_DIR_ . $js)) {
        echo '<script type="text/javascript" src="'. _ITSTOCK_JS_DIR_ . $js .'"></script>';
      }
    }
  }
}

function itstock_html_base_header(&$page_info) {
?>
<!DOCTYPE html>
<html>
  <head>
  <title><?php echo itstock_array_value($page_info, 'title')?></title>
  <meta name="viewport" content="width=device-width" />
  <link rel="shortcut icon" href="favicon.ico">
  <?php
    itstock_html_print_css($page_info);
    itstock_html_print_js($page_info);
  ?>
  </head>
  <body>
    <div id="container">
      <?php
      itstock_html_header();
      ?>
      <div id="page">
<?php
}

function itstock_html_base_footer() {
?>
      </div>
      <div id="footer">IT Stock Tool - Benson Communications &reg;</div>
    </div>
  </body>
</html>
<?php
}

}
?>
